﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Cgd.Shell.Data;

public partial class MasterPage : System.Web.UI.MasterPage
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
			BuildNavTree();
	}

	private void BuildNavTree()
	{
		int activecol = 0;
		if(!string.IsNullOrEmpty(Request["c"]))
		{
			int.TryParse(Request["c"], out activecol);
		}

		tvwNav.Nodes.Clear();

		TreeNode n = new TreeNode("首页");
		n.NavigateUrl = "~/Default.aspx";
		tvwNav.Nodes.Add(n);

		TreeNode nl = new TreeNode("管理网站链接");
		nl.NavigateUrl = "~/Links.aspx";
		n.ChildNodes.Add(nl);

		if(activecol == 0)
			n.Expand();
		else
			n.Collapse();

		foreach (CgdColumn c in CgdColumn.AllColumns)
		{
			TreeNode nc = new TreeNode(c.Title);
			nc.NavigateUrl = "~/DocumentList.aspx?c=" + c.Value;

			TreeNode nrd = new TreeNode("抓取RSS文章");
			nrd.NavigateUrl = "~/RssDoc.aspx?c=" + c.Value;
			nc.ChildNodes.Add(nrd);

			TreeNode nr = new TreeNode("配置RSS源");
			nr.NavigateUrl = "~/RssFeed.aspx?c=" + c.Value;
			nc.ChildNodes.Add(nr);

			tvwNav.Nodes.Add(nc);

			if(c.Value == activecol)
				nc.Expand();
			else
				nc.Collapse();
		}
	}
}
